package com.onlyxiahui.common.action.description.enums.type;

/**
 * Description <br>
 * Date 2020-01-08 09:21:07<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public enum ActionType {

	/**
	 * get
	 */
	get("get"),
	/**
	 * post
	 */
	post("post"),
	/**
	 * put
	 */
	put("put"),
	/**
	 * delete
	 */
	delete("delete"),
	/**
	 * head
	 */
	head("head"),
	/**
	 * patch
	 */
	patch("patch"),
	/**
	 * options
	 */
	options("options"),
	/**
	 * trace
	 */
	trace("trace"),
	/**
	 * tcp
	 */
	tcp("tcp");

	private String type;

	ActionType(String type) {
		this.type = type;
	}

	public String type() {
		return type;
	}

	public void type(String type) {
		this.type = type;
	}

	public static String getValueByType(String type) {
		ActionType actionType = getByType(type);
		return null == actionType ? null : actionType.type;
	}

	public static ActionType getByType(String type) {
		ActionType actionType = null;
		ActionType[] values = ActionType.values();
		for (ActionType v : values) {
			if (v.type.equals(type)) {
				return v;
			}
		}
		return actionType;
	}
}
